﻿using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using ZeldoEngine;
using ZeldoEngineObjects;

namespace MapEditorXna.Background
{
    public class EditorBackground
    {
        private Texture2D _backgroundTexture;
        private int _width;
        private int _height;

        public EditorBackground()
        {
            this._width = 800;
            this._height = 560;
        }

        public void SetSize(int w, int h)
        {
            this._width = w;
            this._height = h;
        }

        public void LoadContent(ContentManager content)
        {
            this._backgroundTexture = content.Load<Texture2D>("background");
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            var tSize = EngineConsts.TILE_SIZE;

            for (int w = 0; w <= this._width / tSize; w++)
            {
                for (int h = 0; h <= this._height / tSize; h++)
                {
                    spriteBatch.Draw(this._backgroundTexture, new Rectangle(w * tSize, h * tSize, tSize, tSize), Color.White);
                }
            }
        }

        public void DrawMapBackground(SpriteBatch spriteBatch, int width, int height)
        {
            spriteBatch.Draw(this._backgroundTexture, new Rectangle(0, 0, width, height), Color.Black);
        }
    }
}
